using UnityEngine;
using UnityEditor;

namespace JufGame
{
	[CustomEditor(typeof(LOD_Character))]
	public class Character_Inspector : Editor
	{
		LOD_Character character;
		SerializedProperty renderer;
		SerializedProperty saturationSize;
		SerializedProperty criticalityVector;
		MonoScript monoScript;
		bool foldout = true;
		private struct MenuCreator
		{
			public FeatureEnum featureEnum;
		}
		private void OnEnable()
		{
			character = target as LOD_Character;
			renderer = serializedObject.FindProperty("observability").FindPropertyRelative("renderer");
			saturationSize = serializedObject.FindProperty("observability").FindPropertyRelative("saturationSize");
			criticalityVector = serializedObject.FindProperty("criticalityVector");
			monoScript = MonoScript.FromMonoBehaviour(target as MonoBehaviour);
		}
		public override void OnInspectorGUI()
		{
			EditorGUILayout.BeginVertical();
			serializedObject.Update();

			EditorGUI.BeginDisabledGroup(true); // 开始禁用 GUI 控件
       		EditorGUILayout.ObjectField("Script", monoScript, typeof(MonoScript), false);
        	EditorGUI.EndDisabledGroup(); 
			EditorGUILayout.PropertyField(renderer, new GUIContent("观测对象"));
			EditorGUILayout.Space(0.5f);
			EditorGUILayout.PropertyField(serializedObject.FindProperty("featureGraph"), new GUIContent("特征图"));
			EditorGUILayout.Space(0.5f);
			EditorGUILayout.PropertyField(saturationSize, new GUIContent("参考饱和度"));
			EditorGUILayout.Space(0.5f);
			if(GUILayout.Button("设置当前大小为参考饱和度"))
			{
				character.UI_GetCurrentSaturation();	
			}
			EditorGUILayout.Space();
			foldout = EditorGUILayout.Foldout(foldout, "重要程度向量", true);
			if (foldout)
			{
				EditorGUI.indentLevel++; // 增加缩进，使子字段缩进
				EditorGUILayout.LabelField("US-BIR", criticalityVector.vector3Value.x.ToString());
				EditorGUILayout.LabelField("FD-BIR", criticalityVector.vector3Value.y.ToString());
				EditorGUILayout.LabelField("ULTB-BIR", criticalityVector.vector3Value.z.ToString());
				EditorGUI.indentLevel--; // 恢复缩进
			}
			EditorGUILayout.Space();
			EditorGUILayout.LabelField("当前特征解决方案", character.Feature_Solution.OnlyID.ToString());
			serializedObject.ApplyModifiedProperties();
			EditorGUILayout.EndVertical();
		}
	}
}
